package com.gm.sfc;

import static com.gm.sfc.field.ColumnField.*;
import static com.gm.sfc.util.Utility.*;

import java.util.HashMap;
import java.util.LinkedList;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.gm.sfc.adapter.SearchAdapter;
import com.gm.sfc.field.IField;
import com.gm.sfc.logic.SearchLogic;
import com.gm.sfc.util.LogUtil;

/**
 * Search Activity
 * @author $Author: segen.der.gottin@gmail.com $
 * @version $Revision: 18 $
 */
public class SearchActivity extends BaseActivity {
    private static final String TAG = "SearchActivity";
    private ListView mListView;
    private SearchAdapter mSearchAdapter;
    private LinkedList<HashMap<IField, Object>> mLinkedList;
    private HashMap<IField, Object> mHashMap;
    private SearchLogic mSearchLogic;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
        mSearchLogic = SearchLogic.getInstance();
        mListView = customFindViewById(this, R.id.list_view);
        mLinkedList = mSearchLogic.getList();
        mSearchAdapter = new SearchAdapter(getApplicationContext(), mLinkedList);
        mListView.setAdapter(mSearchAdapter);
        mListView.setOnItemClickListener(new OnItemClickListener() {
            @SuppressWarnings("unchecked")
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                mHashMap = (HashMap<IField, Object>) parent.getAdapter().getItem(position);
                LogUtil.logD(TAG, getHashmap(mHashMap, title));
            }
        });
    }
}
